package com.atguigu.springtestdemo.controller;

import com.atguigu.springtestdemo.bean.TCustomer;
import com.atguigu.springtestdemo.service.TCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TCustomerController {

    @Autowired
    TCustomerService customerService;

    /*@PostMapping("/insert")
    public String insert(@RequestBody TCustomer customer){
        customerService.insertCustomer(customer);
        return "success";
    }

    @PostMapping("/update")
    public String update(@RequestBody TCustomer customer){
        customerService.updateCustomer(customer);
        return "success";
    }*/

    @PostMapping("/delete/{id}")
    public String delete(@PathVariable("id") Integer id){
        customerService.deleteCustomer(id);
        return "success";
    }

    @GetMapping("/select/{id}")
    public String select(@PathVariable("id") Integer id){

        return  customerService.selectCustomer(id).toString();
    }
}
